package org.sun.web.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import org.apache.log4j.Logger;





public class PropsUtil {
	
	private final Logger logger=Logger.getLogger(getClass());

	public List<String> getPropParams(String propName){
		String path="/"+propName+".properties";
		Properties prop=new Properties();
		InputStream is=Object.class.getResourceAsStream(path);
		logger.debug("加载properties from :"+path);
		List<String> pms=new ArrayList<String>();
		try {
			prop.load(is);
			Set<Object> params=prop.keySet();
			for(Object param:params){
				pms.add(param.toString());
			}
			if(pms.size()>0)return pms;
			return null;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public static void main(String[] args) {
		PropsUtil propUtil=new PropsUtil();
		List<String> props=propUtil.getPropParams("jdbc");
		for(Object prop:props){
			System.out.println(prop);
		}
	}
}
